import java.io.*;


public class BlockIterator {
	private InputStream in;
	private int bufferSize;
	private byte[] buffer;
	private boolean done = false;
	
	public BlockIterator(File file, int recordSize, int sizeInRecords) throws IOException {
		this.bufferSize = recordSize * sizeInRecords;
		this.buffer = new byte[bufferSize];
		this.in = new BufferedInputStream(new FileInputStream(file), bufferSize);
		next();
	}
	
	@Override
	protected void finalize() throws Throwable {
		this.in.close();
		this.in = null;
		super.finalize();
	}
	
	public boolean done() {
		return this.done;
	}
	
	public void next() throws IOException {
		this.done = (this.in.read(buffer) == -1);
	}
	
	public byte[] data() {
		return this.buffer;
	}
	
	public static void main(String[] args) throws IOException {
		// File file = File(...)
		File file = new File("test");
		// File out = File(...)
		File out = new File("test.out");
		// writing out
		OutputStream outStream = new FileOutputStream(out);
		// for (buffer :: file of Data[1])
		for (BlockIterator iter = new BlockIterator(file, Data.size(), 1); !iter.done(); iter.next()) {
		byte[] buffer = iter.data();
		// out <- buffer
		outStream.write(buffer);
		outStream.write(62);
		// for (buffer :: file of Data[1])
		}
		// writing out
		outStream.close();
	}
}
